﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Easily._02_Form.KimiAI
{
    internal class ConversationHistory
    {
        public List<string> _messages = new List<string>();
        private const int MaxHistorySize = 5; // 保存最后5条消息

        public void AddMessage(string message)
        {
            _messages.Insert(0, message); // 将新消息插入列表开头
            if (_messages.Count > MaxHistorySize)
            {
                _messages.RemoveAt(MaxHistorySize); // 保持列表只有最后5条消息
            }
        }

        public IEnumerable<string> GetRecentMessages()
        {
            return _messages;
        }

        public void ClearHistory()
        {
            _messages.Clear();
        }
    }
}
